<template>
  <div class="uploadData">
    <el-upload
      :action="actionUrl"
      :auto-upload="true"
      :headers="myHeaders"
      :on-success="handleChange"
      :show-file-list="false"
    >
      <el-button type="primary" size="small">导入</el-button>
    </el-upload>
  </div>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
  data() {
    return {
      actionUrl: '/checc-api/user/import', //上传文件url
      myHeaders: {
        Authorization: 'Bearer ' + getToken(),
      },
    }
  },
  methods: {
    handleChange(response) {
      if (response == true) {
        this.$message({
          type: 'success',
          message: '导入成功',
        })
        this.$parent.adminList()
      } else {
          this.$message({
          type: 'error',
          message: response,
        })
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.uploadData {
  margin: 0 60px 0 -50px;
}
</style>
